package demo1;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class test {
    ArrayList<String> songList = new ArrayList<String>();
    public static void main(String[] args) {
        new test().go();
    }
    public void go(){
        getSongs();
        System.out.println(songList);
        System.out.println("=================================================================");
        Collections.sort(songList);
        System.out.println(songList);
    }
    void getSongs(){
        try{
            File file = new File("D:\\javacode1103\\javacode1103\\Head First Java\\src\\demo1\\SongList.txt");
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line=null;
            while((line=reader.readLine())!=null){
                addSong(line);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    void addSong(String lineToParse){
        String[] tokens = lineToParse.split("/");
        songList.add(tokens[0]);
    }
}
